# include <bits/stdc++.h>
# define MAXN 1000023
using namespace std;

inline int gn() {
    int k = 0, f = 1;
    char c = getchar();
    for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
    for(; isdigit(c); c = getchar()) k = k * 10 + c - '0';
    return k * f;
}

struct edge {
    edge *ne;
    int t, w;
    edge() {;}
    edge(int t_, int w_, edge *ne_) {
        t = t_, w = w_, ne = ne_;
    }
} *head[MAXN];

int n, m, frm[MAXN];
double ans;

inline void addedge(int fr, int to, int w) {
    head[fr] = new edge(to, w, head[fr]);
    frm[fr]++;
}

inline void dfs(int x, double k, double d) {
    if(x == n) {
        ans += k * d;
        return;
    }
    for(edge *e = head[x]; e; e = e->ne) {
        dfs(e->t, k / (double) frm[x], d + (double) e->w);
    }
}

int main() {
    freopen("ldfrog.in", "r", stdin);
    freopen("ldfrog.out", "w", stdout);
    n = gn(), m = gn();
    for(int i = 1; i <= m; i++) {
        int f = gn(), t = gn();
        addedge(f, t, gn());
    }
    dfs(1, 1.0, 0.0);
    printf("%.2lf", ans);
}
